package com.ruoyi.images.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.images.domain.ApartmentImages;
import com.ruoyi.images.service.IApartmentImagesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓图片管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/images/images")
public class ApartmentImagesController extends BaseController
{
    @Autowired
    private IApartmentImagesService apartmentImagesService;

    /**
     * 查询公寓图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('images:images:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApartmentImages apartmentImages)
    {
        startPage();
        List<ApartmentImages> list = apartmentImagesService.selectApartmentImagesList(apartmentImages);
        return getDataTable(list);
    }

    /**
     * 导出公寓图片管理列表
     */
    @PreAuthorize("@ss.hasPermi('images:images:export')")
    @Log(title = "公寓图片管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApartmentImages apartmentImages)
    {
        List<ApartmentImages> list = apartmentImagesService.selectApartmentImagesList(apartmentImages);
        ExcelUtil<ApartmentImages> util = new ExcelUtil<ApartmentImages>(ApartmentImages.class);
        util.exportExcel(response, list, "公寓图片管理数据");
    }

    /**
     * 获取公寓图片管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('images:images:query')")
    @GetMapping(value = "/{imageId}")
    public AjaxResult getInfo(@PathVariable("imageId") Long imageId)
    {
        return success(apartmentImagesService.selectApartmentImagesByImageId(imageId));
    }

    /**
     * 新增公寓图片管理
     */
    @PreAuthorize("@ss.hasPermi('images:images:add')")
    @Log(title = "公寓图片管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApartmentImages apartmentImages)
    {
        return toAjax(apartmentImagesService.insertApartmentImages(apartmentImages));
    }

    /**
     * 修改公寓图片管理
     */
    @PreAuthorize("@ss.hasPermi('images:images:edit')")
    @Log(title = "公寓图片管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApartmentImages apartmentImages)
    {
        return toAjax(apartmentImagesService.updateApartmentImages(apartmentImages));
    }

    /**
     * 删除公寓图片管理
     */
    @PreAuthorize("@ss.hasPermi('images:images:remove')")
    @Log(title = "公寓图片管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageIds}")
    public AjaxResult remove(@PathVariable Long[] imageIds)
    {
        return toAjax(apartmentImagesService.deleteApartmentImagesByImageIds(imageIds));
    }
}
